﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEditor;

namespace Nirvana
{
    [Serializable]
    public sealed class AssetCheckReport
    {
        [SerializeField]
        private List<AssetCheckReportItem> reports = new List<AssetCheckReportItem>();
        public List<AssetCheckReportItem> Reports { get { return reports; } }
        public string assetpath,objectname, hierarchyPath;


        public void Clear()
        {
            reports.Clear();
        }

        public void ShowWarnInfo(string msg)
        {
            var item = new AssetCheckReportItem();
            item.Serverity = AssetCheckReportItem.ServerityType.Warn;
            item.AssetGUID = AssetDatabase.AssetPathToGUID(this.assetpath);
            item.ObjectName = objectname;
            item.HierarchyPath = hierarchyPath;
            item.Message = msg;
            this.reports.Add(item);
        }
        public void ShowWarnInfo(string msg,params object[] args)
        {
            var item = new AssetCheckReportItem();
            item.Serverity = AssetCheckReportItem.ServerityType.Warn;
            item.AssetGUID = AssetDatabase.AssetPathToGUID(this.assetpath);
            item.ObjectName = objectname;
            item.HierarchyPath = hierarchyPath;
            item.Message = string.Format(msg,args);
            this.reports.Add(item);
        }
        public void ShowErrorInfo(string msg)
        {
            var item = new AssetCheckReportItem();
            item.Serverity = AssetCheckReportItem.ServerityType.Error;
            item.AssetGUID = AssetDatabase.AssetPathToGUID(this.assetpath);
            item.ObjectName = objectname;
            item.HierarchyPath = hierarchyPath;
            item.Message = msg;
            this.reports.Add(item);
        }

        public void ShowErrorInfo(string msg, params object[] args)
        {
            var item = new AssetCheckReportItem();
            item.Serverity = AssetCheckReportItem.ServerityType.Error;
            item.AssetGUID = AssetDatabase.AssetPathToGUID(this.assetpath);
            item.ObjectName = objectname;
            item.HierarchyPath = hierarchyPath;
            item.Message = string.Format(msg, args);
            this.reports.Add(item);
        }

    }
}

